'use strict';
app.service('modulesEditService',['$q','utilService',function($q,utilService){
    var _this_=this;
    _this_.modules={};

    _this_.findById= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'modules/'+$scope.id
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错");
        })
        return deferred.promise;
    }

    _this_.editModules= function ($scope) {
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'modules/',
            data:_this_.modules,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    _this_.findNoPageAll = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'column/all',
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    }


}]);